package org.cyb.demo.service.impl;

import org.cyb.demo.dao.SectionMapper;
import org.cyb.demo.domain.Chapter;
import org.cyb.demo.domain.Section;
import org.cyb.demo.service.SectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("sectionService")
public class SectionServiceImpl implements SectionService {
    @Autowired
    private SectionMapper sectionMapper;

    @Override
    public int add(Section section, Chapter chapter) {
        return sectionMapper.insert(section,chapter);
    }

    @Override
    public void remove(Section section) {
        sectionMapper.delete(section);
    }

    @Override
    public void modify(Section section) {
        sectionMapper.update(section);
    }

    @Override
    public List<Section> find(Section section) {
        return sectionMapper.selectByName(section);
    }

    @Override
    public List<Section> findAll() {
        return sectionMapper.selectAll();
    }

    @Override
    public Section findOneById(Section section) {
        return sectionMapper.selectOneById(section);
    }
}
